<?php
/**
 * 权限表
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/8
 * Time: 16:35
 */

namespace App\Http\Controllers\Admin;


use App\Http\Logics\Admin\AuthLogic;
use App\Http\Traits\AuthTrait;
use App\Http\Controllers\BaseController;
class AuthController extends BaseController
{
    use AuthTrait;
    public function getAuthList()
    {
        $limit = $this->limit;
        $type = $this->type;
        $name = $this->name;
        $menu_id = $this->menu_id;
        $data = [
            'limit' => $limit,
            'type' => $type,
            'name' => $name,
            'menu_id' => $menu_id
        ];
        $response = AuthLogic::getAuthList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function createAuth()
    {
        $type = $this->type;
        $name = $this->name;
        $route = $this->route;
        $data = [
            'name' => $name,
            'route' => $route,
            'type' => $type
        ];
        $response = AuthLogic::createAuth($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function deleteAuth()
    {
        $id = $this->id;
        $data = [
            'id'=> $id
        ];
        $response = AuthLogic::deleteAuth($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function updateAuth()
    {
        $id = $this->id;
        $name = $this->name;
        $route = $this->route;
        $type = $this->type;
        $data = [
            'id' => $id,
            'name' => $name,
            'route' => $route,
            'type' => $type
        ];
        $response = AuthLogic::updateAuth($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}